﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using IDML.BusinessObject;
using IDML.BusinessLogic;


namespace IDML.Web.Controls
{
    /// <summary>
    /// Summary description for AutoComplete
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    [System.Web.Script.Services.ScriptService]
    public class AutoComplete : System.Web.Services.WebService
    {

        [WebMethod]
        public string[] GetCompletionList(string prefixText, int count)
        {
            if (count == 0)
            {
                count = 10;
            }

            if (prefixText.Equals("xyz"))
            {
                return new string[0];
            }

            PatientBL patientBL = new PatientBL();

            List<PatientBO> pbList = patientBL.Patient_SearchWithText(prefixText);

            Random random = new Random();
            List<string> items = new List<string>(count);

            foreach (PatientBO item in pbList)
            {
                items.Add(item.FirstName + " " + item.LastName);
            }
            return items.ToArray();
        }
    }
}
